package com.servlet.req; /**
 * @author wzm
 * @create 2024-01-27 16:13
 * project_name:JavaWeb2401
 * @Description 测试请求的转发
 */

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/win2")
public class Window2 extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //窗口2
        System.out.println("我是窗口2，请问你哪里不舒服? 请出示小票");
        Object piao = request.getAttribute("piao");
        System.out.println("piao = " + piao);
        /*request.removeAttribute();*/

        //转发到a.html  WEB-INF下
        //request.getRequestDispatcher("/WEB-INF/a.html").forward(request,response);
        //不可以访问服务器以外的资源
        request.getRequestDispatcher("http://www.baidu.com").forward(request,response);


    }
}
